import shutil
import os

def remake_dir(path):
    # 去除首位空格
    path = path.strip()
    # 去除尾部 \ 符号
    path = path.rstrip("\\")
    remove_dir(path)
    os.makedirs(path)
    print(path + ' 创建成功')
    return True


def remove_dir(path):
    if os.path.exists(path):
        shutil.rmtree(path)
        print(path + ' 删除成功')
    return True


def move_dir(newPath, oldPath):
    remove_dir(oldPath)
    shutil.move(newPath, oldPath)


def move_file(newFile, oldFile):
    if os.path.exists(oldFile):
        os.remove(oldFile)
    shutil.move(newFile,oldFile)


class MYException(BaseException):
    def __init__(self, value):
        self.value = value

    def __str__(self):
        return repr(self.value)
